using System;
using System.Net.Sockets;
using System.Threading;
using System.Net;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;

namespace rudp
{
	class MainClass
	{
		public static void Main (string[] args)
		{
            Socket server = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            server.Bind(new IPEndPoint(IPAddress.Any, 5000));

            CommunicationState serverState = new CommunicationState ();
            serverState.Buffer = new byte[1500];
            serverState.Socket = server;
            serverState.RemoteHost = new IPEndPoint(IPAddress.Any, 0);

            Server serverQueue = new Server();
            serverQueue.Initialize();

            DeliveryQueue queue = new DeliveryQueue( Receipt);
			queue.Initialize ();

			byte[] data = File.ReadAllBytes ("rudp.exe");

			List<Message> messages = MessageManager.Instance.CreateMessagePacketList (data, 10, 1400);

			CommunicationState state = new CommunicationState ();
			state.Buffer = new byte[1500];
			state.Packets = messages;
            state.RemoteHost = new IPEndPoint (IPAddress.Any, 5000);
			state.Socket = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
			queue.Add (state);

			Thread.Sleep (1000000);
		}

        public static void Receipt( CommunicationState state )
        {

        }
	}

}
